package Hot100.Medium.GreedyAndDP.DynamicPlanning;

public class LC647_NumOfSubStrings {
    public static void main(String[] args) {

    }

    // 中心扩散法
    public int countSubstrings(String s){
        int len = s.length();
        int ans = 0;
        for(int i = 0; i < 2 * len - 1; i++){
            int left = i / 2;
            int right = left + i % 2;
            while(left >= 0 && right < len && s.charAt(left) == s.charAt(right)){
                ans++;
                left--;
                right++;
            }
        }
        return ans;
    }
}
